package map;

class Solution {
    //无重复字符的最长子串
    public int lengthOfLongestSubstring(String s) {
        //数组模拟哈希表,通过下标进行定位
        int[] arr = new int[128];
        int l = 0;
        int r = 0;
        char[] ss = s.toCharArray();
        int n = s.length();
        int len = 0;
        while(r < n){
            arr[ss[r]]++;
            while(arr[ss[r]] > 1){
                arr[ss[l++]]--;
            }
            len = Math.max(len,r-l + 1);
            r++;
        }
        return len;
    }
}